package com.csy.ocmis.controller;


import com.csy.ocmis.entity.Cashier;
import com.csy.ocmis.entity.Outpatienttype;
import com.csy.ocmis.entity.Pharmacy;
import com.csy.ocmis.service.IOutpatienttypeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 * 项目
 * @author csy
 * @since 2020-11-30
 */
@RestController
@RequestMapping("/outpatienttype")
public class OutpatienttypeController {

    @Autowired
    private IOutpatienttypeService outpatienttypeService;
    //查询药品所有信息
    @RequestMapping("selout")
    public Object seldrug(Outpatienttype coutpatienttype, Integer page, Integer limit, String projectName){
        coutpatienttype.setProjectName(projectName);
        PageHelper.startPage(page, limit);
        List<Pharmacy> selout = outpatienttypeService.selout(coutpatienttype);
        PageInfo pageInfo = new PageInfo(selout);
        Map<String, Object> tableData = new HashMap<String, Object>();
        //这是layui要求返回的json数据格式，如果后台没有加上这句话的话需要在前台页面手动设置
        tableData.put("code", 0);
        tableData.put("msg", "");
        //将全部数据的条数作为count传给前台（一共多少条）
        tableData.put("count", pageInfo.getTotal());
        //将分页后的数据返回（每页要显示的数据）
        tableData.put("data", pageInfo.getList());
        return tableData;
    }

}

